<?php

class Server extends Model {

	private $listItemsOnShoppingListStatement;
	private $listPackageTypeIdsStatement;

	function __construct(){
		parent::__construct();
		$this->listItemsOnShoppingListStatement = parent::prepareStatement("SELECT * FROM v_stocks WHERE on_shoplist = 1");
	}
	
	function listItemsOnShoppingList(){
		$this->listItemsOnShoppingListStatement->execute();
		$this->listItemsOnShoppingListStatement->bind_result($product_name, $package_name, $metric_system_unit_name, $quantity, $amount_available, $amount_desired, $on_shoplist, $kCal, $natrium, $product_id, $package_unit_id, $stock_id, $metric_system_unit_id);

		$resultSet = array();
		/* fetch values */
		while ($this->listItemsOnShoppingListStatement->fetch()) {
			//printf ("%s (%s)\n", $package_unit_id, $package_unit);
			array_push($resultSet, array($product_name, $package_name, $metric_system_unit_name, $quantity, $amount_available, $amount_desired, $on_shoplist, $kCal, $natrium, $product_id, $package_unit_id, $stock_id, $metric_system_unit_id));
		}
		return $resultSet;
	}
}

